/*
 * This is written by Lulu Han.
 * E-mail: locomotive_crypto@163.com
 */

// Secure Comparison
#include "paillier.h"
#include "sec_mul.h"

#ifndef PPSPD_SEC_CMP_H
#define PPSPD_SEC_CMP_H

class SecCmp{
public:
	class CloudA{
	public:
		CloudA(const PrivateKey& pri);
		void set_nvlen(long nlens, long vlens);
		
		void dec_sub(const NTL::ZZ& sub, NTL::ZZ& beta);
		
		void dec_reenc(const NTL::ZZ& nca, const NTL::ZZ& ncb, NTL::ZZ& cmul);
	private:
		Decryptor m_dec;
		long m_nlens, m_vlens;
		SecMul::CloudA m_mulA;
	};
	
	
	class CloudB{
	public:
		CloudB(const PublicKey& pub);
		void set_nvlen(long nlens, long vlens);
		
		void calc_sub(const NTL::ZZ& cx, const NTL::ZZ& cy, NTL::ZZ& sub);
		void rerandom_for_mul(const NTL::ZZ& cbeta, NTL::ZZ& nca, NTL::ZZ& ncb);
		void gen_res(const NTL::ZZ& cmul, NTL::ZZ& ccmp);
	private:
		Encryptor m_enc;
		long m_nlens, m_vlens;
		NTL::ZZ m_alpha;
		SecMul::CloudB m_mulB;
	};	
};

#endif // PPSPD_SEC_CMP_H


